package com.tripcube.common.redis.key;

import org.springframework.context.annotation.Configuration;

import java.time.YearMonth;

@Configuration
public class UserProviderCacheKeyBuilder extends RedisKeyBuilder {

    /**
     * 生成用户签到Bitmap的key
     * 格式: tripcube:user:{userId}:checkin:bitmap
     * @param userId 用户ID
     * @return Redis key
     */
    public String buildCheckinBitmapKey(Long userId) {
        return buildKey("user", userId, "checkin", "bitmap");
    }

    /**
     * 生成用户签到天数统计的key
     * 格式: tripcube:user:{userId}:checkin:days
     * @param userId 用户ID
     * @return Redis key
     */
    public String buildCheckinDaysKey(Long userId) {
        return buildKey("user", userId, "checkin", "days");
    }

    /**
     * 生成用户连续签到天数的key
     * 格式: tripcube:user:{userId}:checkin:continuous
     * @param userId 用户ID
     * @return Redis key
     */
    public String buildContinuousDaysKey(Long userId) {
        return buildKey("user", userId, "checkin", "continuous");
    }

    /**
     * 生成用户旅行打卡次数的key
     * 格式: tripcube:user:{userId}:checkin:travel:count
     * @param userId 用户ID
     * @return Redis key
     */
    public String buildTravelCountKey(Long userId) {
        return buildKey("user", userId, "checkin", "travel", "count");
    }

    /**
     * 生成用户月度积分的key
     * 格式: tripcube:user:{userId}:checkin:points:monthly:{yearMonth}
     * @param userId 用户ID
     * @param yearMonth 年月
     * @return Redis key
     */
    public String buildMonthlyPointsKey(Long userId, YearMonth yearMonth) {
        return buildKey("user", userId, "checkin", "points", "monthly", yearMonth.toString());
    }
}
